package dgut.party.business.entity.base;

import com.fasterxml.jackson.annotation.JsonIgnore;
import dgut.party.business.entity.rbac.Authority;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;

import javax.persistence.*;
import java.util.List;

@ToString
@Getter
@Setter
@Entity
@SuperBuilder
@NoArgsConstructor
public class Menu extends BaseEntity {

  private static final long serialVersionUID = 9090033350397337040L;

  private String name;

  @OneToOne
  private Authority auth;

  @JsonIgnore
  @ManyToOne(cascade = CascadeType.ALL)
  private Menu supMenu;

  @Column(length = 50)
  private String icon;

  @JsonIgnore
  @OneToMany(fetch = FetchType.LAZY, mappedBy = "supMenu", cascade = CascadeType.ALL)
  private List<Menu> subMenus;
}
